<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>

<head>
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css">
    <script src="${ctx}/layui/jquery.js"></script>
</head>

<body>
<div class="layui-card layui-anim layui-anim-upbit">
    <div class="layui-card-header">
        <!-- <i class="layui-icon layui-icon-website" style="font-size: 30px; color: #bbbbbb;"></i> -->
        <a onclick="prev()"><i class="layui-icon layui-icon-left"></i></a>
        <span style="font-size: 20px;">信息修改</span>
        <span style="float: right"> <a onclick="refresh()"><i class="layui-icon layui-icon-refresh"></i></a></span>
    </div>
    <div class="layui-card-body">

        <form lay-filter="edit-panel" action="" class="layui-form">
            <div style="display: none">
                <input name="id">
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                    <input name="username" class="layui-input" lay-verType="tips" disabled></input>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input name="password" type="password" class="layui-input" lay-verType="tips"></input>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-block">
                    <input name="email" type="email" lay-verify="email" class="layui-input" lay-verType="tips"></input>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">真实姓名</label>
                <div class="layui-input-block">
                    <input name="realName" class="layui-input" lay-verType="tips"></input>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block">
                    <input type="radio" name="sex" value="1" title="男">
                    <input type="radio" name="sex" value="0" title="女">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">生日</label>
                <div class="layui-input-block">
                    <input class="layui-input" lay-verify="date" type="text" id="birth" name="birth">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">学校</label>
                <div class="layui-input-block">
                    <input name="school" class="layui-input" lay-verType="tips"></input>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">专业</label>
                <div class="layui-input-block">
                    <input name="major" class="layui-input" lay-verType="tips"></input>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button lay-submit class="layui-btn layui-btn-normal" lay-filter="ff">提交</button>
                    <button onclick="refresh()" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>

    </div>
</div>


</body>
<script src="${ctx}/layui/layui.all.js"></script>
<script>
    layui.use(['form', 'element', 'laydate'], function () {
        var form = layui.form;
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#birth' //指定元素
        });
        form.on("submit(ff)", data => {
            $.ajax({
                url: "${ctx}/user/update",
                type: "post",
                dataType: "json",
                contentType: "application/json",
                data: JSON.stringify(data.field),
                success: res => {
                    if (res.code == 1) {
                        layer.msg(res.data);
                    } else {
                        layer.msg(res.msg);
                    }

                },
                error: res => {
                    alert(res.msg)
                }
            })
            return false;
        })
        form.val("edit-panel", ${userinfo});
    })
</script>
<script>
    function prev() {
        history.go(-1);
    }

    function refresh() {
        window.location.reload()
    }
</script>
</html>
<style>
    .layui-card {
        margin-bottom: 5%;
    }
</style>